package org.qiyu.live.living.provider.rpc;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import jakarta.annotation.Resource;
import org.apache.dubbo.config.annotation.DubboService;
import org.dubbo.live.common.interfaces.dto.PageWrapper;
import org.dubbo.live.common.interfaces.enums.CommonStatusEum;
import org.dubbo.live.common.interfaces.utils.ConvertBeanUtils;
import org.qiyu.live.living.interfaces.dto.LivingRoomReqDTO;
import org.qiyu.live.living.interfaces.dto.LivingRoomRespDTO;
import org.qiyu.live.living.interfaces.rpc.ILivingRoomRpc;
import org.qiyu.live.living.provider.dao.mapper.LivingRoomMapper;
import org.qiyu.live.living.provider.dao.po.LivingRoomPO;
import org.qiyu.live.living.provider.service.ILivingRoomService;
import org.qiyu.live.living.provider.service.ILivingRoomTxService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * @Description: //todo
 * @Author: 张广焱
 * @Date: 2024-05-17 下午10:03
 */
@DubboService
public class LivingRoomRpcImpl implements ILivingRoomRpc {
    @Resource
    private ILivingRoomService livingRoomService;
    @Autowired
    private LivingRoomMapper livingRoomMapper;
    @Resource
    private ILivingRoomTxService livingRoomTxService;


    @Override
    public List<Long> queryUserIdByRoomId(LivingRoomReqDTO livingRoomReqDTO) {
        return livingRoomService.queryUserIdByRoomId(livingRoomReqDTO);
    }

    /**
     * @Description: 直播间列表分页查询
     * @Author: 张广焱
     * @Date: 2024-05-19  20:47:46
     */
    @Override
    public PageWrapper<LivingRoomRespDTO> list(LivingRoomReqDTO livingRoomReqDTO) {
        return livingRoomService.list(livingRoomReqDTO);
    }

    /**
     * @Description: 开播
     * @Author: 张广焱
     * @Date: 2024-05-19  20:45:54
     */
    @Override
    public Integer startLivingRoom(LivingRoomReqDTO livingRoomReqDTO) {
        return livingRoomService.startLivingRoom(livingRoomReqDTO);
    }

    /**
     * @Description: 关播
     * @Author: 张广焱
     * @Date: 2024-05-19  20:45:42
     */
    @Override
    public boolean closeLiving(LivingRoomReqDTO livingRoomReqDTO) {
        return livingRoomTxService.closeLiving(livingRoomReqDTO);
    }

    /**
     * @Description: 根据用户id查询是否开播
     * @Author: 张广焱
     * @Date: 2024-05-19  20:45:22
     */
    @Override
    public LivingRoomRespDTO queryByRoomId(Integer roomId) {
        return  livingRoomService.queryByRoomId(roomId);
    }
}
